import rclpy
from rclpy.node import Node
from rclpy.parameter import Parameter


class SimpleParameter(Node):
    def __init__(self):
        super().__init__('simple_parameter')
        self.declare_parameter('string_param', 'default_string')
        self.declare_parameter('int_param', 42)
        self.get_logger().info(f"Parameter 'my_param' is set to: {self.get_parameter('my_param').get_parameter_value().string_value}")
        self.set_parameters([rclpy.parameter.Parameter('my_param', rclpy.Parameter.Type.STRING, 'new_value')])
        self.add_on_set_parameters_callback(self.parameter_callback)

    def parameter_callback(self, params):
        for param in params:
            if param.name == 'string_param' and param.type_ == rclpy.Parameter.Type.STRING:
                self.get_logger().info(f"Parameter 'string_param' changed to: {param.value}")
            elif param.name == 'int_param' and param.type_ == rclpy.Parameter.Type.INTEGER:
                self.get_logger().info(f"Parameter 'int_param' changed to: {param.value}")
        return rclpy.parameter.SetParametersResult(successful=True)


def main(args=None):
    rclpy.init(args=args)
    simple_parameter_node = SimpleParameter()
    rclpy.spin(simple_parameter_node)
    simple_parameter_node.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()